package day0310;

import java.io.File;
import java.util.Arrays;
import java.util.Date;

public class FileDemo {


    public static void main(String[] args) {
        File file = new File("D:/abc.txt");
//        file = new File("d:/aa", "temp\\abc.txt");
//        File file1 = new File(file, "aaa.ext");
//        System.out.println(file1);

        System.out.println(file.exists()); // false

        System.out.println(file.isFile()); // fasle
        System.out.println(file.isDirectory()); // false

        file = new File("d:/gitee地址.txt");
        System.out.println(file.exists()); // true

        System.out.println(file.isFile()); // true
        System.out.println(file.isDirectory()); // false

        System.out.println(file.isAbsolute());

        System.out.println(file.getName());
        System.out.println(file.getPath());
        System.out.println(file.getAbsolutePath());

        long l = file.lastModified();
        System.out.println(new Date(l).toLocaleString());

        System.out.println(file.length());

        File file1 = new File("D:\\work\\docs\\考试\\01");

        System.out.println(file1.exists());
        System.out.println(file1.length());

        String[] list = file1.list();
        File[] files = file1.listFiles();
        System.out.println(Arrays.toString(list));
        System.out.println(Arrays.toString(files));


        System.out.println(file.getParent());
        System.out.println(file1.getParent());

        System.out.println(file.canRead());
        System.out.println(file.canWrite());
        System.out.println(file.canExecute());
    }
}

